<template>
	<view class="bg-white radius-lg padding relative">
		<!-- <view class="top-status">
			{{selectDictLabel(dict.type.assign_orders_status,orderData.status)}}
		</view> -->
		<view class="top-status">
			{{ topStatusLabel }}
		</view>
		<view class="text-lg text-bold padding-bottom-sm solid-bottom">
			<text class="cuIcon-titles" :class="theme == 'fs'?'color-blue':'color-green'"></text>
			<text class="text-black">订单信息</text>
		</view>

		<view class="flex align-center margin-tb-sm">
			<view class="item-label">
				订单编号
			</view>
			<view class="flex-sub text-black">
				{{orderData.orderCode}}
			</view>
		</view>
		<view class="flex align-center margin-tb-sm">
			<view class="item-label">
				订单任务
			</view>
			<view class="flex-sub text-black">
				{{orderData.orderName}}
			</view>
		</view>
		<template v-if="orderData.homeworkType == 1">
		<view class="flex align-center margin-tb-sm">
			<view class="item-label">
				作物种类
			</view>
			<view class="flex-sub text-black">
				<!-- {{selectDictLabel(cropTypeOpt,orderData.cropType)}} -->
				{{orderData.cropName}}
			</view>
		</view>
		<view class="flex align-center margin-tb-sm">
			<view class="item-label">
				作物面积
			</view>
			<view class="flex-sub text-black">
				{{orderData.area}} 亩
			</view>
		</view>
		<view class="flex align-center margin-tb-sm" v-if="orderData.orderType == 1">
			<view class="item-label">
				亩用量
			</view>
			<view class="flex-sub text-black">
				{{ orderData.cropAcreUsage || '-' }}L/亩
			</view>
		</view>
		<view class="flex align-start margin-tb-sm" v-if="orderData.orderType == 0">
			<view class="item-label">
				药物要求
			</view>
			<view class="flex-sub text-black">
				<text> {{ orderData.drugRequire || '-' }}</text>
			</view>
		</view>
		</template>
		<template v-else>
			<view class="flex align-center margin-tb-sm">
				<view class="item-label">
					货物类型
				</view>
				<view class="flex-sub text-black">
					{{orderData.cropName}}
				</view>
			</view>
			<view class="flex align-center margin-tb-sm">
				<view class="item-label">
					吊运重量
				</view>
				<view class="flex-sub text-black">
					{{orderData.area}} 吨
				</view>
			</view>
		</template>
		<view class="flex align-start margin-tb-sm">
			<view class="item-label">
				作业地址
			</view>
			<view class="flex-sub flex align-start justify-between">
				<view class="text-black" @click="onNavigation">
					<text class="cuIcon-location"
						:class="theme == 'fs'?'color-blue':'color-green'"></text>{{orderData.address}}

				</view>
				<view :class="theme == 'fs'?'color-blue':'color-green'">
					{{orderData.distance || ''}}
				</view>
			</view>
		</view>
		<view class="flex align-center margin-tb-sm">
			<view class="item-label">
				推荐作业时间
			</view>
			<view class="flex-sub text-black">
				{{orderData.dockingPeopleTime || '-'}}
			</view>
		</view>
		<view class="flex align-center margin-tb-sm">
			<view class="item-label">
				预估金额
			</view>
			<view class="flex-sub flex align-center justify-between">
				<view class="color-red">
					<text class="text-sm">￥</text>
					<text class="text-lg text-bold">{{orderData.actualMoney || orderData.money}}</text>
				</view>
				<view class="text-bold" :class="theme == 'fs'?'color-blue':'color-green'" @click="showExpain">
					<text class="cuIcon-question"></text>
					<text class="margin-left-xs">金额说明</text>
				</view>
			</view>
		</view>
		<view class="flex margin-tb-sm" v-if="orderData.remarks">
			<view class="item-label">
				备注
			</view>
			<view class="flex-sub text-black">
				{{orderData.remarks}}
			</view>
		</view>

		<uv-modal ref="modal" title="金额说明" confirmText="知道了" :confirmColor="theme == 'fs'?'#4CA0FF':'#0BCA89'"
			@confirm="confirm">
			<view class="slot-content">
				<view class="margin-bottom">
					1.此金额为预估金额
				</view>
				<view class="">
					2.实际金额您可以与单方沟通后修改确认
				</view>
			</view>
		</uv-modal>
	</view>
</template>

<script>
	import {
		selectDictLabel
	} from '@/utils/huida.js'
	import {
		mapGetters
	} from 'vuex'
	export default {
		dicts: ["assign_orders_status"],
		props: {
			orderData: {
				type: Object,
				default: () => ({})
			},
		},
		data() {
			return {
				cropTypeOpt: []
			}
		},
		// 飞手端
		computed: {
			...mapGetters(['theme']),
			topStatusLabel() {
				const {status,isStatus,commentStar,exceptionType,frozenReason} = this.orderData
				// console.log('8888888', this.theme);
				// console.log('99999', this.orderData);
				// console.log('status',status);
				// console.log('isStatus',isStatus);

				if (frozenReason && frozenReason.trim() !== '') {
					return selectDictLabel(this.dict.type.assign_orders_status, '18');
				}

				let s = String(status);
				const is1 = String(isStatus) === '1';
				const is2 = String(isStatus) === '2';
				const is3 = String(isStatus) === '3';

				if(exceptionType == 2 && s == 13) {
					return selectDictLabel(this.dict.type.assign_orders_status, s, 'reserved1');
				}
				if(exceptionType == 2 && s == 14) {
					return selectDictLabel(this.dict.type.assign_orders_status, s, 'reserved1');
				}
				if(s === '17'){
					return selectDictLabel(this.dict.type.assign_orders_status, '1');
				}
				// 农户订单状态
				if (this.theme === 'farmer') {
					// console.log('isStatus', isStatus);
					// console.log('111111', s);
					if (s === '6' && is2) {
						s = '8';
					}
					if (s === '6' && is3) {
						s = '8';
					}
					if (s === '7' && is1) {
						s = '8';
					}
					if (s === '8' && is2) {
						s = '8';
					}
					if (s === '9' && is1 && commentStar == null) {
						s = '8';
					}
					if (commentStar != null) {
						s = '9';
					}
				}

				if (this.theme === 'farmer' && ['1', '2', '6', '7', '8'].includes(s)) {
					return selectDictLabel(this.dict.type.assign_orders_status, s, 'reserved1');
				}
				// 如果status=4 && isStatus=2，使用10的字典值
				if (s === '4' && is2) {
					return selectDictLabel(this.dict.type.assign_orders_status, '10');
				}
				// 走原逻辑
				return selectDictLabel(this.dict.type.assign_orders_status, s);
				//抢单状态
				// return "待抢单";
			}
		},
		created() {
			uni.$uv.http.get('/cadre/highSeasOrder/cropType').then(res => {
				this.cropTypeOpt = res.data.map(item => ({
					name: item.dictLabel,
					label: item.dictLabel,
					value: item.dictValue
				}))
			})
		},
		methods: {
			selectDictLabel,
			showExpain() {
				this.$refs.modal.open();
			},
			confirm() {},
			onNavigation() {
				uni.$uv.route({
					url: '/subPages/pages/navigation/index',
					params: {
						latitude: this.orderData.lat,
						longitude: this.orderData.lng,
						name: this.orderData.address,
						title: this.orderData.orderName
					}
				})
			}
		},
	}
</script>

<style scoped>
	.top-status {
		position: absolute;
		top: 0;
		right: 0;
		padding: 10rpx 20rpx;
		font-size: 24rpx;
		color: #fff;
		background: linear-gradient(90deg, #006BFE, #2A84FF);
		border-radius: 0rpx 20rpx 0rpx 20rpx;
	}

	.item-label {
		width: 120rpx;
		font-weight: 500;
		font-size: 28rpx;
		color: #A7A7B5;
		text-align: right;
		margin-right: 40rpx;
	}
</style>